#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

int maxValue(int** grid, int gridSize, int* gridColSize);

int main()
{
	return 0;
}

int maxValue(int** grid, int gridSize, int* gridColSize)
{
	int* dp = calloc(*gridColSize, sizeof(int));

	for (int row = 0; row < gridSize; row++) {
		dp[0] += grid[row][0];
		for (int col = 1, lenC = *gridColSize; col < lenC; col++)
			dp[col] = fmax(dp[col - 1], dp[col]) + grid[row][col];
	}

	int res=dp[*gridColSize-1];
	free(dp);return res;
}
